package com.lemon.smartsafety.ui.adapter.main;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.lemon.smartsafety.entity.main.MainRcvItemBase;
import com.lemon.smartsafety.ui.adapter.common.RcvViewType;
import com.lemon.smartsafety.ui.adapter.common.SectionHeadView;

import java.util.List;

import kale.adapter.CommonRcvAdapter;
import kale.adapter.item.AdapterItem;

/**
 * Created by Cooliean on 16/2/6.
 */
public class MainFragmentAdapter extends CommonRcvAdapter<MainRcvItemBase> {
    //private LoggerHelper loggerHelper = new LoggerHelper(MainFragmentAdapter.class);

    private List<MainRcvItemBase> mItems;


    public MainFragmentAdapter(@Nullable List<MainRcvItemBase> data) {
        super(data);
        this.mItems = data;

    }

    @Override
    public int getItemCount() {
        return this.mItems.size();


    }

    @Override
    public Object getItemType(MainRcvItemBase mainRcvItemBase) {
        return mainRcvItemBase.getViewType();
    }

    @NonNull
    @Override
    public AdapterItem createItem(Object type) {
        RcvViewType.MainRcvViewType myType = (RcvViewType.MainRcvViewType) type;
        if (myType == RcvViewType.MainRcvViewType.TYPE_AD) {
            return new MainAdItemView();
        } else if (myType == RcvViewType.MainRcvViewType.TYPE_MAIN_OPTION) {
            return new MainOptionItemViewRec();
        } else if (myType == RcvViewType.MainRcvViewType.TYPE_NEWS_COLUMN) {
            return new MainNewsColumnItemView();
        }
        return new SectionHeadView();
    }


}
